<template>
    <div class="components-container">
        <div class="header-form">
        </div>
        <div>
            <ul class="toolList">
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                    <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                    
                </li>
                <li> <el-button type="primary" @click="getData">刷新</el-button></li>
            </ul>
           
        </div>
        <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
        <sweet-modal ref="info" class="dialog" :sweetModalMaxWidth="maxWidth">
            <h3>{{title}}</h3>
            <div style=" width:700px; margin:30px 50px">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">逝者姓名</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKNAME" readonly></el-input>
                        </div>
                        <label class="layui-form-label">死亡原因</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKCAUSA" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">审批类型</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKTYPEDESC" readonly></el-input>
                        </div>
                        <label class="layui-form-label">逝者性别</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKSEXDESC" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">家属姓名</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKHANDLERNAME" readonly></el-input>
                        </div>
                        <label class="layui-form-label">家属电话</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKHANDLERLINK" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">司机姓名</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKCARRYDRIVER" readonly></el-input>
                        </div>
                        <label class="layui-form-label">司机电话</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKCARRYTEL" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">运出单位</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKOUTUNIT" readonly></el-input>
                        </div>
                        <label class="layui-form-label">接收单位</label>
                        <div class="layui-input-inline">
                            <el-input v-model="dataInfo.BAKINUNIT" readonly></el-input>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">死亡日期</label>
                        <div class="layui-input-inline">
                            <el-date-picker v-model="dataInfo.BAKDEATHDATE" readonly></el-date-picker>
                        </div>
                        <label class="layui-form-label">运出日期</label>
                        <div class="layui-input-inline">
                            <el-date-picker v-model="dataInfo.BAKOUTDATE" readonly></el-date-picker>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">逝者住址</label>
                            <div class="layui-input-inline">
                                <el-input v-model="dataInfo.BAKDETAILADDRESS" style="width:465px;" readonly></el-input>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item btnCenter">
                <el-button @click="infoClose">取消</el-button>
            </div>
        </sweet-modal>
    </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>
<script>
    import dataTable from "@/components/Table/DataTable";
    import {
        manage
    } from "@/mixins/managePage.js";
    import apiBase from "@/api/apiBase.js";
    import sweetModal from "@/components/sweetModal";
    const ACCEPT = "受理"
    const TRANSACT = "办结"
    const INFO = "详情"
    export default {
        name: "cemeteryapprove",
        mixins: [manage],
        data() {
            return {
                maxWidth: 700,
                title: null,
                dataInfo: {},
            }
        },
        methods: {
            //获取表头
            getCarColumns() {
                let data = {};
                apiBase.DoService(
                    data,
                    apiBase.getApiAdress().Column.GetRemoteBackColumns,
                    res => {
                        this.headList = res.data.content;
                    }
                );
            },
            getData() {
                let Data = {};
                let data = {
                    PageIndex: this.pageOrder.currentPage,
                    PageSize: this.pageOrder.pageSize,
                    OrderBy: this.pageOrder.orderType,
                    OrderByType: this.pageOrder.orderSort,
                    Data: Data
                };
                apiBase.DoService(data, apiBase.getApiAdress().InterfaceUpload.QueryBak, res => {
                    this.dataList = res.data.content.OutData;
                    this.pageOrder.totalNum = res.data.content.RecordCount;
                });
            },
            //功能操作
            operate(order) {
                this.order = order;
                switch (this.order) {
                    case ACCEPT:
                        this.$confirm('是否受理?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            this.acceptInfoAps();
                        }).catch(() => {
                            this.$message({
                                type: 'info',
                                message: '已取消受理'
                            });
                        });
                        break;
                    case TRANSACT:
                        this.$confirm('是否办结?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            this.transactInfoAps();
                        }).catch(() => {
                            this.$message({
                                type: 'info',
                                message: '已取消办结'
                            });
                        });
                        break;
                    case INFO:
                        this.title = "详情"
                        this.dataDetail();
                        break;
                    default:
                }
            },
            //受理
            acceptInfoAps() {
                let Data = {
                    BAKID: this.currentRow.BAKID
                };
                
                apiBase.DoService(Data, apiBase.getApiAdress().InterfaceUpload.AcceptInfoBak, res => {
                 
                    this.$message({
                        type: 'success',
                        message: '受理成功!'
                    });
                    this.getData();
                     console.log('受理')
                });
            },
            //办结
            transactInfoAps() {
                let Data = {
                    BAKID: this.currentRow.BAKID
                };
                apiBase.DoService(Data, apiBase.getApiAdress().InterfaceUpload.TransactInfoBak, res => {
                    
                    this.$message({
                        type: 'success',
                        message: '办结成功!'
                    });
                    this.getData();
                    console.log('办结')
                });
            },
            //详情
            dataDetail() {
                let Data = {
                    BAKID: this.currentRow.BAKID
                };
                apiBase.DoService(Data, apiBase.getApiAdress().InterfaceUpload.DetailBak, res => {
                    this.dataInfo = res.data.content;
                    this.$refs.info.open();
                });
            },
            btnShow(btn) {
              
                if(this.currentRow != null){
                    if (this.currentRow.BAKSTATUS === 'A') {
                        return btn === ACCEPT
                    } else if (this.currentRow.BAKSTATUS === 'B') {
                        return btn === TRANSACT
                    } else {
                        return false;
                    }
                }
            },
           
        },
        created() {
            this.getCarColumns();
            this.getData();
        },
        components: {
            sweetModal,
            dataTable
        }
    };
</script>

